#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int T,n,rt,in[N],a[N],b[N],up[N],flg;
vector<int> e[N];

void dfs(int u,int f){	
	for(int v:e[u]){
		if(v==f) continue;
		dfs(v,u);
		if(!flg) return;
	}
	if(in[u]==1) b[f]+=a[u],up[u]=a[u];
	else if(!f){
		if(b[u]!=2*a[u]){
			flg=0;
			return;
		}
		for(int v:e[u]){
			if(up[v]>a[u]){
				flg=0;
				return;
			}
		}
	}
	else{
		if(b[u]>2*a[u]||b[u]<a[u]){
			flg=0;
			return;
		}
		int s2=b[u]-a[u],s1=a[u]-s2;
		b[f]+=s1,up[u]=s1;
		for(int v:e[u]){
			if(v==f) continue;
			if(up[v]>s2+s1){
				flg=0;
				return;
			}
		}
	}
}

signed main(){
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	T=read();
	while(T--){
		n=read();
		for(int i=1;i<=n;i++) a[i]=read();
		for(int u,v,i=1;i<n;i++){
			u=read(),v=read();
			e[u].emplace_back(v);
			e[v].emplace_back(u);
			in[u]++,in[v]++;
		}
		
		if(n==1){
			if(a[1]>0) puts("NO");
			else puts("YES");
			for(int i=1;i<=n;i++) e[i].clear(),in[i]=b[i]=up[i]=0;
			continue;
		}
		if(n==2){
			if(a[1]==a[2]) puts("YES");
			else puts("NO");
			for(int i=1;i<=n;i++) e[i].clear(),in[i]=b[i]=up[i]=0;
			continue;
		}
		
		for(int i=1;i<=n;i++)
			if(in[i]>1) rt=i;
		flg=1,dfs(rt,0);
		flg?puts("YES"):puts("NO");
		for(int i=1;i<=n;i++) e[i].clear(),in[i]=b[i]=up[i]=0;
	}
	return 0;
}
